<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>批量分配</title>
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<!-- 使用struts 2的 datetimepicher 必须有这个头文件 -->
		<s:head />
		<!--打印CSS-->
		<style type="text/css" media="print">
.Noprint {
	display: none;
}

.AutoNewline {
	word-break: break-all; /*必须*/
}

.PageNext {
	page-break-after: always;
}
</style>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/dormitoryAllocateAction.js'>
			</script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/studentAction.js'>
		</script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/studentLodgeMgrAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
			<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/forCSS.js'></script>
			<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>			
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/forCSS.js'></script>
		<script type='text/javascript'>
			$j(function(){
				tbCSS();
			})
		</script>
		<script type="text/javascript">
//===============
//全局变量
var studentpreid;  //学生预分配标记id
var dormitorypreid //宿舍预分配标记id;
var stutotalcount =-1;
var dormtotalcount =-1;
var stuCache={};
var dormCache={};
var stupage;   //dwr分页的page对象，注意在页面中是一个Json对象
var dormpage;   //dwr分页的page对象，注意在页面中是一个Json对象
var stuIdList = new Array(); //学生id数组
var dormIdList = new Array();//宿舍id数组
var liveCountNum = 0; //所有选中房间的可住人员总数

///===========================我是讨厌的分割线=====================================
//载入预分配allcationinfo的内容
function setAllocationInfo(){
	return dormitoryAllocateAction.getAllAllocationInfo(aicallback);
}
var aicallback = function aicall_back(aiList){
	 var sp = $("studpreassign");
	 var dp = $("dormpreassign");
	DWRUtil.removeAllOptions(sp);  
	sp.options[0] = new Option("学生预分配值",'0');
	for ( var i = 1; i < aiList.length+1; i++) {
		var opt = new Option(aiList[i-1].allocationname,
				aiList[i-1].allocationid);
		sp.options[i] = opt;
	}
	DWRUtil.removeAllOptions(dp);  
	dp.options[0] = new Option("公寓预分配值",'0');
	for ( var j = 1; j < aiList.length+1; j++) {
		var optt = new Option(aiList[j-1].allocationname,
				aiList[j-1].allocationid);
		dp.options[j] = optt;
	}
}
//载入预分配allcationinfo的内容结束

//给选择的预分配置赋值
function selectChange(){
	studentpreid = $("studpreassign").options[$("studpreassign").selectedIndex].value; //studentpreid赋值
	dormitorypreid = $("dormpreassign").options[$("dormpreassign").selectedIndex].value;//dormitorypreid赋值
}


///===========================我是讨厌的分割线=====================================
//===学生查询和分页函数===by 李双江 09/04/05
//查询总行数
function searchStudentTotalCount(){
	if($('studataTable').style.visibility == 'visible'){
		$('studataTable').style.visibility = 'hidden';
	}
	if($('stupageTable').style.visibility == 'visible'){
		$('stupageTable').style.visibility = 'hidden';
	}

	//alert(studentpreid)
	stuIdList.length = 0;
	stuIdList = new Array();
	$('stuListCount').innerHTML = "";
	if(studentpreid==undefined||studentpreid==0){
		alert("请选择学生预分配值");
		return ;
		}
		studentAction.getStudentByStudentPreIDRows(studentpreid,stucbck); //查询学生
}

var stucbck = function tc_bck(bckcount){
	stutotalcount = bckcount; // 给总行数赋值
    studentAction.getStudentPerPageByPreID(1,bckcount,studentpreid,renderstucallback);
}

var renderstucallback = function renderstucb(stuprelist){
	if(stuprelist==null){
		if($('checkallstupresent').style.visibility == 'visible'){
			$('checkallstupresent').style.visibility = 'hidden';
		}
		if($('stuListCount').style.visibility == 'visible'){
			$('stuListCount').style.visibility = 'hidden';
		}
		alert("查询指定预分配标记的学生结果为空!");
		return false;
	}

	if($('studataTable').style.visibility == 'hidden'){
		$('studataTable').style.visibility = 'visible';
	}
	if($('stupageTable').style.visibility == 'hidden'){
		$('stupageTable').style.visibility = 'visible';
	}
	if($('checkallstupresent').style.visibility == 'hidden'){
		$('checkallstupresent').style.visibility = 'visible';
	}
	if($('checkallstu').style.visibility == 'hidden'){
		$('checkallstu').style.visibility = 'visible';
	}

	DWRUtil.removeAllRows('stuttb', { filter:function(tr) {
	      return (tr.id != "stupattern");
		    }});
	var stud,sid;
	 for (var i =0; i < stuprelist.length ; i++) {
		 stud = stuprelist[i];
		  sid = stud[0];
		  //alert(stud[7])
		  //alert(stud[20])
		 dwr.util.cloneNode("stupattern", { idSuffix:sid });
	     dwr.util.setValue("stutableid"+sid, stud[0]);//隐藏项
	     dwr.util.setValue("stutablename"+sid, stud[2]);	 //学生姓名
	     dwr.util.setValue("stutablestuno"+sid, stud[1]); //学生学号
	     dwr.util.setValue("stutablesex"+sid,stud[8]); //学生性别
	     dwr.util.setValue("stutableenrollyear"+sid,stud[7]); //入学年份
	     dwr.util.setValue("stutableeducationyear"+sid,stud[20]); //学制四年
	 
	 if(typeof(stud[6])=="object"){
	     dwr.util.setValue("stutableclass"+sid,""); //学生所在班级
	 }else{
 	    dwr.util.setValue("stutableclass"+sid,stud[6]); //学生所在班级
	 }    
	    
	 if(typeof(stud[30])=="object"){
	     dwr.util.setValue("stutablescolle"+sid,""); //学院
	 }else{
 	    dwr.util.setValue("stutablescolle"+sid,stud[30]); //学院
	 }  
	      
	 if(typeof(stud[31])=="object"){
	   dwr.util.setValue("stutablemaj"+sid,""); //专业
	 }else{
 	   dwr.util.setValue("stutablemaj"+sid,stud[31]); //专业
	 }
	      
	      
	      dwr.util.setValue("stucbx" + sid, stud[0]);
	 	 $("stupattern" + sid).style.display= "";
	 	stuCache[sid] = stud;
	   }
	   	setstuPageInfo();
	   	tbCSS();
		}

function setstuPageInfo(){
	$('stupageTd').innerHTML = '';
	studentAction.getStuPage({
		callback:function(data){
		stupage = data;
			//显示 当前页/总页数
			if(stupage.totalPage != 0){
				var stupageSpan = document.createElement('span');
				stupageSpan.innerHTML = '共 '+stutotalcount+' 条 '+'   第 '+stupage.currentPage+' 页    共'+stupage.totalPage+' 页 ';
				$('stupageTd').appendChild(stupageSpan);
				var stuaFirst = document.createElement('a');
				stuaFirst.setAttribute('href','javascript:getstuFirstData()');
				stuaFirst.innerHTML = '首页';
				$('stupageTd').appendChild(stuaFirst);
				var stuaPrevious = document.createElement('a');
				stuaPrevious.setAttribute('href','javascript:getstuPreviousData()');
				stuaPrevious.innerHTML = '前一页';
				$('stupageTd').appendChild(stuaPrevious);
				var stuaNext = document.createElement('a');
				stuaNext.setAttribute('href','javascript:getstuNextData()');
				stuaNext.innerHTML = '下一页';
				$('stupageTd').appendChild(stuaNext);
				var stuaLast = document.createElement('a');
				stuaLast.setAttribute('href','javascript:getstuLastData()');
				stuaLast.innerHTML = '末页';
				$('stupageTd').appendChild(stuaLast);
			}
		}
	});
	$('stuloading').style.display = 'none';
	judgeStudentCheckboxInNewPage();
}

function getstuFirstData(){
	stupage.currentPage = 1;
	getstuDataPerPage();
}

function getstuPreviousData(){

 	if(stupage.currentPage>1){
            stupage.currentPage--;
        }
	getstuDataPerPage();
}

function getstuNextData(){
	if(stupage.currentPage<stupage.totalPage){
            stupage.currentPage++;
        }
	getstuDataPerPage();
}

function getstuLastData(){
	stupage.currentPage = stupage.totalPage;
	getstuDataPerPage();
}


function getstuDataPerPage(){
	$('stuloading').style.display = 'block';
	studentAction.getStudentPerPageByPreID(stupage.currentPage,stutotalcount,studentpreid,renderstucallback);
}	

function checkStudentIdList(str){
	if(stuIdList.length == 0){
		return -1;
	}
	for(var a=0 ;a<stuIdList.length;a++){
		if(str == stuIdList[a][0]){
			return a;
		}else continue;
	}
	return -1;
}
function checkCheckboxInStudentIdList(obj){
	var p = checkStudentIdList(obj.id.substr(6));
	if(p == -1 && obj.checked == true){  
		var a = stuIdList.length;
		stuIdList[a] = new Array();
		stuIdList[a][0] = obj.id.substr(6); //stucbx123
		stuIdList[a][1] = $('stutablename' + obj.id.substr(6)).innerHTML;
		stuIdList[a][2] = $('stutableenrollyear' + obj.id.substr(6)).innerHTML;
		stuIdList[a][3] = $('stutableeducationyear' +  obj.id.substr(6)).innerHTML;
		//alert(stuIdList);
		//alert(stuIdList.length);
	}
	if(p != -1 && obj.checked == false){
		stuIdList.splice(p,1);
		//alert(stuIdList);
	}
	if($('stuListCount').style.visibility == 'hidden'){
		$('stuListCount').style.visibility = 'visible';
	}
	$('stuListCount').innerHTML = "选中 "+(stuIdList.length)+" 个学生";
}
//dwr分页中，当进入到新的页面时判断当前页的checkbox是否曾经被选中，并存入了stuIdList中
function judgeStudentCheckboxInNewPage(){
		var a=document.getElementsByTagName("input");  
       	for(var i=0;i<a.length;i++){  
             if(a[i].type=='checkbox' && a[i].id.substr(0,6)== "stucbx"){  
                 if(checkStudentIdList(a[i].id.substr(6)) != -1){
                 	 a[i].checked = true;
                 }else{
                 	 a[i].checked = false;
                 }
             }
        }
        $('stuSelectAll').checked = false;
}

function selectCurrentPageStu(){
	var   a=document.getElementsByTagName("input");  
	if($('stuSelectAll').checked == true){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,6) == "stucbx" && a[i].id != "stucbx" ) { 
	       		a[i].checked = true ;
	       		checkCheckboxInStudentIdList(a[i]);
	       }
	    }
    }
    if($('stuSelectAll').checked == false){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,6) == "stucbx" && a[i].id != "stucbx" ) { 
	       		a[i].checked = false ;
	       		checkCheckboxInStudentIdList(a[i]);
	       }
	    }
    }
    $('stuListCount').innerHTML = "选中 "+(stuIdList.length)+" 个学生";
}
function selectAllPageStu(){
	if($('stuSelectAllPage').checked == false){
		var   a=document.getElementsByTagName("input");  
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,6) == "stucbx" && a[i].id != "stucbx" ) { 
	       		a[i].checked = false ;
	       }
	    }
	    stuIdList.length = 0;
	    if($('stuListCount').style.visibility == 'hidden'){
			$('stuListCount').style.visibility = 'visible';
	    }
	    $('stuListCount').innerHTML = "选中 "+(stuIdList.length)+" 个学生";
	    return;
    }
	studentAction.getStudentIDListByStudentPreID(studentpreid,getStudentIDListByStudentPreIDCallback);
}
var getStudentIDListByStudentPreIDCallback = function getStudentIDListByStudentPreIDCallbackFunc(s){
	stuIdList = s;
	var   a=document.getElementsByTagName("input");  
	if($('stuSelectAllPage').checked == true){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,6) == "stucbx" && a[i].id != "stucbx" ) { 
	       		a[i].checked = true ;
	       }
	    }
    }
    if($('stuListCount').style.visibility == 'hidden'){
		$('stuListCount').style.visibility = 'visible';
	}
    $('stuListCount').innerHTML = "选中 "+(stuIdList.length)+" 个学生";
}

///===========================我是讨厌的分割线=====================================
//查询指定预分配标记的宿舍
function searchDormitoryTotalCount(){
	if($('dormdataTable').style.visibility == 'visible'){
		$('dormdataTable').style.visibility = 'hidden';
	}
	if($('dormpageTable').style.visibility == 'visible'){
		$('dormpageTable').style.visibility = 'hidden';
	}

	//alert(dormitorypreid);
	//把上次查询的结果情况
	liveCountNum = 0;
	dormIdList.length = 0;
	dormIdList = new Array();
	$('dormListCount').innerHTML = "";
	if(dormitorypreid==undefined||dormitorypreid==0){
		alert("请选择公寓预分配值");
		return ;
		}
	dormitoryAllocateAction.getDormitoryByDormitoryPreIDRows(dormitorypreid,dormcbck); //查询宿舍
}

var dormcbck = function dorm_cbck(dormbckcount){
	dormtotalcount = dormbckcount; // 给总行数赋值
	dormitoryAllocateAction.getDormitoryPerPageByPreID(1,dormtotalcount,dormitorypreid,renderdormcallback);
}

var renderdormcallback = function renderdormcb(dormprelist){
	if(dormprelist==null){
		if($('dormListCount').style.visibility == 'visible'){
			$('dormListCount').style.visibility = 'hidden';
		}
		if($('liveCount').style.visibility == 'visible'){
			$('liveCount').style.visibility = 'hidden';
		}
		if($('checkalldormpresent').style.visibility == 'visible'){
			$('checkalldormpresent').style.visibility = 'hidden';
		}
	alert("查询指定预分配标记的宿舍结果为空!");
	return false;
	}

	if($('checkalldormpresent').style.visibility == 'hidden'){
		$('checkalldormpresent').style.visibility = 'visible';
	}
	if($('checkalldorm').style.visibility == 'hidden'){
		$('checkalldorm').style.visibility = 'visible';
	}
	if($('dormdataTable').style.visibility == 'hidden'){
		$('dormdataTable').style.visibility = 'visible';
	}
	if($('dormpageTable').style.visibility == 'hidden'){
		$('dormpageTable').style.visibility = 'visible';
	}

	DWRUtil.removeAllRows('dormttb', { filter:function(tr) {
	      return (tr.id != "dormpattern");
		    }});
	var dor,did ;
	 for (var i =0; i < dormprelist.length ; i++) {
		 dor = dormprelist[i];
		 did = dor[0]; //宿舍id
		 dwr.util.cloneNode("dormpattern", { idSuffix:did });
	     dwr.util.setValue("dormtableid"+did, dor[0]);//隐藏项
	     dwr.util.setValue("dormtablename"+did, dor[5]); //宿舍显示名称
	     dwr.util.setValue("dormtablefees"+did, dor[9]); //住宿费用
	     //根据domitoryid去查该宿舍的可住人数
	     //DWREngine.setAsync(false); //同步执行dwr(nb！)
		 //dormitoryAllocateAction.getAvailBedNoByDormitoryID(did,{
				//	callback:function(availbed) {
			//		}
				//});
		dwr.util.setValue("dormtableroomtype"+did, dor[8]);	 //房型
		dwr.util.setValue("dormtableallowstudent"+did, dor[15]);	 //可住人数			
	     if(dor[6]==0){
	      dwr.util.setValue("dormtablesex"+did,"女");
	     }
	     if(dor[6]==1){
	      dwr.util.setValue("dormtablesex"+did,"男");
	     }
	    dwr.util.setValue("dormcbx" + did, dor[0]);
	 	$("dormpattern" + did).style.display= "";
	 	dormCache[did] = dor;
	    }
	   	setdormPageInfo();
	   	tbCSS();
		}


function setdormPageInfo(){
        $('dormpageTd').innerHTML = '';
        dormitoryAllocateAction.getDormPage({     
            callback:function(data){
                dormpage = data;
                if(dormpage.totalPage != 0){
                    var dormpageSpan = document.createElement('span');
                    dormpageSpan.innerHTML = '共 '+dormtotalcount+' 条 '+'   第 '+dormpage.currentPage+' 页    共'+dormpage.totalPage+' 页 ';
                    $('dormpageTd').appendChild(dormpageSpan);
                    var dormaFirst = document.createElement('a');
                    dormaFirst.setAttribute('href','javascript:getdormFirstData()');
                    dormaFirst.innerHTML = '首页';
                    $('dormpageTd').appendChild(dormaFirst);
                    var dormaPrevious = document.createElement('a');
                    dormaPrevious.setAttribute('href','javascript:getdormPreviousData()');
                    dormaPrevious.innerHTML = '上一页 ';
                    $('dormpageTd').appendChild(dormaPrevious);
                    var dormaNext = document.createElement('a');
                    dormaNext.setAttribute('href','javascript:getdormNextData()');
                    dormaNext.innerHTML = '下一页 ';
                    $('dormpageTd').appendChild(dormaNext);
                    var dormaLast = document.createElement('a');
                    dormaLast.setAttribute('href','javascript:getdormLastData()');
                    dormaLast.innerHTML = '尾页';
                    $('dormpageTd').appendChild(dormaLast);    
                }               
            }
        });
        $('dormloading').style.display = 'none';
        judgeDormCheckboxInNewPage();
    } 

function getdormFirstData(){
	dormpage.currentPage = 1;
	getdormDataPerPage();
}

function getdormPreviousData(){
 	if(dormpage.currentPage>1){
         dormpage.currentPage--;
        }
	getdormDataPerPage();
}

function getdormNextData(){
	 if(dormpage.currentPage<dormpage.totalPage){
            dormpage.currentPage++;
        }
	getdormDataPerPage();
}

function getdormLastData(){
	dormpage.currentPage = dormpage.totalPage;
	getdormDataPerPage();
}



function getdormDataPerPage(){
	$('dormloading').style.display = 'block';
	dormitoryAllocateAction.getDormitoryPerPageByPreID(dormpage.currentPage,dormtotalcount,dormitorypreid,renderdormcallback);
}	

function checkDormitoryIdList(str){
	if(dormIdList.length == 0){
		return -1;
	}
	for(var a=0 ;a<dormIdList.length;a++){
		if(str == dormIdList[a][0]){
			return a;
		}else continue;
	}
	return -1;
}
function checkDormCheckboxInDormitoryIdList(obj){
	var p = checkDormitoryIdList(obj.id.substr(7));
	if(p == -1 && obj.checked == true){
		var a = dormIdList.length;
		dormIdList[a] = new Array();
		dormIdList[a][0] = obj.id.substr(7);
		dormIdList[a][1] = $("dormtablename" + obj.id.substr(7)).innerHTML;
		dormIdList[a][2] = $("dormtablefees" + obj.id.substr(7)).innerHTML;
		liveCountNum += parseInt($("dormtableallowstudent"+obj.id.substr(7)).innerHTML);
		//alert(dormIdList);
	}
	if(p != -1 && obj.checked == false){
		dormIdList.splice(p,1);
		liveCountNum -= parseInt($("dormtableallowstudent"+obj.id.substr(7)).innerHTML);
		//alert(dormIdList);
	}
	if($('dormListCount').style.visibility == 'hidden'){
		$('dormListCount').style.visibility = 'visible';
	}
	if($('liveCount').style.visibility == 'hidden'){
		$('liveCount').style.visibility = 'visible';
	}
	$('dormListCount').innerHTML = "选中 "+(dormIdList.length)+" 间宿舍";
	$('liveCount').innerHTML = "所选房间总可住"+liveCountNum+"人";
}
//dwr分页中，当进入到新的页面时判断当前页的checkbox是否曾经被选中，并存入了dormIdList中
function judgeDormCheckboxInNewPage(){
		var a=document.getElementsByTagName("input");  
      	for(var i=0;i<a.length;i++){  
            if(a[i].type=='checkbox' && a[i].id.substr(0,7)== "dormcbx"){  
                if(checkDormitoryIdList(a[i].id.substr(7)) != -1){
                	 a[i].checked = true;
                }else{
                	 a[i].checked = false;
                }
            }
        }
        $('dormSelectAll').checked = false;
}

function selectCurrentPageDorm(){
	var   a=document.getElementsByTagName("input");  
	if($('dormSelectAll').checked == true){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,7) == "dormcbx" && a[i].id != "dormcbx" ) { 
	       		a[i].checked = true ;
	       		checkDormCheckboxInDormitoryIdList(a[i]);
	       }
	    }
    }
    if($('dormSelectAll').checked == false){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,7) == "dormcbx" && a[i].id != "dormcbx" ) { 
	       		a[i].checked = false ;
	       		checkDormCheckboxInDormitoryIdList(a[i]);
	       }
	    }
    }
    $('dormListCount').innerHTML = "选中 "+(dormIdList.length)+" 间宿舍";
    $('liveCount').innerHTML = "所选房间总可住"+liveCountNum+"人";
}
function selectAllPageDorm(){
	var a=document.getElementsByTagName("input");  
	if($('dormSelectAllPage').checked == false){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,7) == "dormcbx" && a[i].id != "dormcbx" ) { 
	       		a[i].checked = false ;
	       }
	    }
	    dormIdList.length = 0;
	    return;
    }
	dormitoryAllocateAction.getDormitoryIDListByDormitoryPreID(dormitorypreid,getDormitoryIDListByDormitoryPreIDCallback);
}
var getDormitoryIDListByDormitoryPreIDCallback = function (s){
	dormIdList = s;
	var a=document.getElementsByTagName("input");  
	if($('dormSelectAllPage').checked == true){
	 	for(var i=0;i<a.length;i++){  
	       if(a[i].type=='checkbox' && a[i].id.substr(0,7) == "dormcbx" && a[i].id != "dormcbx" ) { 
	       		a[i].checked = true ;
	       }
	    }
    }
    if($('dormListCount').style.visibility == 'hidden'){
		$('dormListCount').style.visibility = 'visible';
	}
	if($('liveCount').style.visibility == 'hidden'){
		$('liveCount').style.visibility = 'visible';
	}
    $('dormListCount').innerHTML = "选中 "+(dormIdList.length)+" 间宿舍";
    $('liveCount').innerHTML = "所选房间总可住"+liveCountNum+"人";
   
	
}



///===========================我是讨厌的分割线=====================================
//批量分配开始了....
function allocateBatchStudent(){
	if(studentpreid==undefined||studentpreid==0){
		alert("请选择学生预分配值");
		return ;
		}
		
	if(dormitorypreid==undefined||dormitorypreid==0){
		alert("请选择公寓预分配值");
		return ;
		}
	if(stuIdList.length==0){ 
		alert("请选择预分配学生");
		return ;
	}
	if(dormIdList.length==0){
		alert("请选择预分配宿舍");
		return ;
	}
	
	//获取入住开始和结束时间 
	var startindate= dojo.widget.byId("startInDate").getValue();
	var endoutdate= dojo.widget.byId("endOutDate").getValue();
	if(startindate==""){
		alert("请选择开始入住时间");
		return ;
	}
	if(endoutdate==""){
		alert("请选择结束入住时间");
		return ;
	}		
	studentLodgeMgrAction.allocateBatchStudent(stuIdList,dormIdList,startindate,endoutdate,$('seleOrder').options[$('seleOrder').selectedIndex].value,allocatebck);
}
var allocatebck = function allocate_bck(status){
	//分配提示 
	alert(status);
	//刷新页面
	searchDormitoryTotalCount();
	searchStudentTotalCount();
	$("allocatestatus").innerHTML=status;
		<!--调用打印函数-->
		//document.all.WebBrowser.ExecWB(6,6)
		//printInfo();
}

//javascript打印div的方法
function printInfo(){
		//alert("进入打印了");
  		var headstr = "<html><head><title></title></head><body>";
		var footstr = "</body></html>";
  		var newstr = $('allocatestatus').innerHTML;
  		var oldstr = document.body.innerHTML;
  		//alert(oldstr);
		document.body.innerHTML = headstr+newstr+footstr;
		//alert(newstr);
		alert(document.body.innerHTML);
		//alert(document.all.WebBrowser);
		window.print();
		//document.all.WebBrowser.ExecWB(6,6) 
		//document.body.innerHTML = oldstr;
		//alert(document.body.innerHTML);
		return false;
}
</script>
	</head>
	<body onload="javascript:setAllocationInfo();">
		<div id="page_container">
			<%@   include file="allocatebanner.jsp"%>
			<h2>
				批量分配宿舍
			</h2>
			<object id=WebBrowser
				classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height="0"
				width="0">
			</object>
			<!-- 学生按预分配标记查询开始 -->
			<div class="divground,Noprint" id="div_ground">
				<div>
					<span style="font-size:16px;">学生预分配</span>
					<select class="common_select" name="studpreassign"
						id="studpreassign" style="width: 120"
						onchange="javascript:selectChange();">
					</select>
					<input class="common_button" type="submit" value=查询
						onclick="javascript:searchStudentTotalCount();">
				</div>
				<!-- 动态显示当前checkbox选中的数量 -->
				<div id="checkallstupresent" style="visibility: hidden; float: left;margin-right:10px;">
					选中当前页
					<input type="checkbox" id="stuSelectAll"
						onclick="selectCurrentPageStu()" />
				</div>
				<div id="checkallstu" style="visibility: hidden; float: left;margin-right:10px;">
					选中所有页
					<input type="checkbox" id="stuSelectAllPage"
						onclick="selectAllPageStu()" />
				</div>
				<div id="stuListCount" style="visibility: hidden; float: left">
					1
				</div>

				<!-- 动态显示当前checkbox选中的数量结束-->
				<!-- 学生列表显示开始 -->
				<table id="studataTable" style="visibility: hidden;" class="table_common table_list_style">
					<thead>
						<tr>
							<th>
								选择
							</th>
							<th>
								姓名
							</th>
							<th>
								学号
							</th>
							<th>
								性别
							</th>
							<th>
								学院
							</th>
							<th>
								专业
							</th>
							<th>
								班级
							</th>
						</tr>
					</thead>
					<tbody id="stuttb">
						<tr id="stupattern" style="display: none;">
							<td>
								<input type="checkbox" id="stucbx" name="stucbx"
									onclick="checkCheckboxInStudentIdList(this)" />
							</td>
							<td style="display: none">
								<div id="stutableid">id</div>
							</td>
							<td style="display: none">
								<div id="stutableenrollyear">enrollyear</div>
							</td>
							<td style="display: none">
								<div id="stutableeducationyear">educationyear</div>
							</td>
							<td>
								<div id="stutablename">name</div>
							</td>
							<td>
								<div id="stutablestuno">stuno</div>
							</td>
							<td>
								<div id="stutablesex">sex</div>
							</td>
							<td>
								<div id="stutablescolle">colle</div>
							</td>
							<td>
								<div id="stutablemaj">maj</div>
							</td>
							<td>
								<div id="stutableclass">class</div>
							</td>
						</tr>
					</tbody>
				</table>
				<table id="stupageTable" align="center" style="visibility: hidden;"
					class="navigator">
					<tr>
						<td id="stupageTd"></td>
					</tr>
				</table>
				<div id="stuloading"
					style="display: none; margin-top: 20px; text-align: center; color: red; font: 13px;">
					Loading...
				</div>
				<!-- 学生列表显示结束 -->
			</div>
			<!-- 学生按预分配标记查询结束 -->
			<!-- 2009/04/24 by paradise -->
			<!-- 宿舍按预分配标记查询开始 -->
			<div class="divground,Noprint" id="div_ground_dorm">
				<div>
					<span style="font-size:16px;">宿舍预分配</span>
					<select class="common_select" name="dormpreassign"
						id="dormpreassign" style="width: 120"
						onchange="javascript:selectChange();">
					</select>
					<input class="common_button" type="submit" value=查询
						onclick="javascript:searchDormitoryTotalCount();">
				</div>
				<!-- 显示用户点击详细统计信息显示开始 -->
				<div id="checkalldormpresent"
					style="visibility: hidden; float: left;margin-right:10px;">
					选中当前页
					<input type="checkbox" id="dormSelectAll"
						onclick="selectCurrentPageDorm()" />
				</div>
				<div id="checkalldorm"
					style="visibility: hidden; float: left;margin-right:10px;">
					选中所有页
					<input type="checkbox" id="dormSelectAllPage"
						onclick="selectAllPageDorm()" />
				</div>
				<!-- 动态显示当前checkbox选中的数量 -->
				<div id="dormListCount" style="visibility: hidden; float: left;margin-right:10px;">
					1
				</div>
				<!-- 动态显示当前所有选中房间可住人数的总和 -->
				<div id="liveCount" style="visibility: hidden; float: left">
					1
				</div>
				<!-- 显示用户点击详细统计信息显示结束 -->
				<!-- 宿舍列表显示开始 -->
				<table class="table_common table_list_style" id="dormdataTable" style="visibility: hidden;">
					<thead>
						<tr>
							<th>
								选择
							</th>
							<th>
								宿舍名称
							</th>
							<th>
								住宿性别
							</th>
							<th>
								房型
							</th>
							<th>
								可住人数
							</th>
						</tr>
					</thead>
					<tbody id="dormttb">
						<tr id="dormpattern" style="display: none;">
							<td>
								<input type="checkbox" id="dormcbx" name="dormcbx"
									onclick="checkDormCheckboxInDormitoryIdList(this)" />
							</td>
							<td style="display: none">
								<div id="dormtableid">id</div>
							</td>
							<td style="display: none">
								<div id="dormtablefees">dormfee</div>
							</td>
							<td>
								<div id="dormtablename">name</div>
							</td>
							<td>
								<div id="dormtablesex">sex</div>
							</td>
							<td>
								<div id="dormtableroomtype">roomtype</div>
							</td>
							<td>
								<div id="dormtableallowstudent">allowstudent</div>
							</td>
						</tr>
					</tbody>
				</table>
				<table id="dormpageTable" align="center"
					style="visibility: hidden; margin-top: 30px; font: 12px;"
					class="navigator">
					<tr>
						<td id="dormpageTd">
						</td>
					</tr>
				</table>
				<div id="dormloading"
					style="display: none; margin-top: 20px; text-align: center; color: red; font: 13px;">
					Loading...
				</div>
			</div>
			<!-- 学生按预分配标记查询开始 -->
			<div align="center" id="startt">
				开始入住时间：
				<s:datetimepicker name="startInDate" id="startInDate"
				value="today" displayFormat="yyyy-MM-dd" />
			</div>
			<div align="center" id="endt">
				结束入住时间：
				<s:datetimepicker name="endOutDate" id="endOutDate"
					displayFormat="yyyy-MM-dd" />
			</div>
			<div id="outlier"></div>
			<div align="center">
				<select id="seleOrder" >
					<option value="asc">顺序分配</option>
					<option value="desc">逆序分配</option>
				</select>
				<input class="common_button" type="button" value="批量分配"
					onclick="javascript:allocateBatchStudent();">
			</div>
			<!-- 打印分配结果-->
			<div style="visibility: hidden;" class="NoNewline"
				id="allocatestatus">
			</div>
		</div>
	</body>
</html>
